<?phpclass Model_users extends CI_Model {		public function get_data($email) {
		$this->db->where('email', $email);
	
		$query = $this->db->get('users');
	
		if($query->num_rows() == 1) {
			return $query->row_array();
		} else {
			return false;
		}
	}		public function update_user($email) {		if($this->input->post('pass')!=''){			$sql = 'update users set password="'.md5($this->input->post('pass')).'",car_no="'.$this->db->escape_str($this->input->post('car_no')).'" where email="'.$this->db->escape_str($email).'"';		} else {			$sql = 'update users set car_no="'.$this->db->escape_str($this->input->post('car_no')).'" where email="'.$this->db->escape_str($email).'"';		}						$this->db->query($sql);		if($this->db->affected_rows()>0) {			return true;		} else {			return false;
		}	}		public function login_ok($email1='',$pass1='') {		if($email1=='' || $pass1=='') {			$this->db->where('email', $this->input->post('email'));			$this->db->where('password', md5($this->input->post('pass')));		} elseif($email1!='' && $pass1!='') {			$this->db->where('email', $email1);
			$this->db->where('password', md5($pass1));		}		$query = $this->db->get('users');		if($query->num_rows() == 1) {			return true;		} else {			return false;		}			}		public function add_temp_user($email='',$pass='',$key) {		if($email==''&&$pass=='') {			$data = array (				'email' => $this->input->post('email'),				'pass' => md5($this->input->post('pass')),				'key' => $key			);		} else {			$email=urldecode($email);			$data = array (
				'email' => $email,
				'pass' => md5($pass),
				'key' => $key
			);		}				$query = $this->db->insert('temp_users', $data);		if($query) {			return true;		} else {			return false;		}	}		public function is_key_valid($key) {		$this->db->where('key', $key);				$query = $this->db->get('temp_users');				if($query->num_rows() == 1) {			return true;		} else {			return false;		}	}		public function add_user($key) {		$this->db->where('key', $key);				$tmp_user = $this->db->get('temp_users');				if($tmp_user) {			$row = $tmp_user->row();						$data = array(				'email' => $row->email,				'pass' => $row->pass			);						$q =  $this->db->insert('users', $data);						if($q) {				$this->db->where('key', $key);				$this->db->delete('temp_users');				return $data['email'];			} else {				return false;			}		}	}		public function valid_email() {		$this->db->where('email', $this->input->post('email'));				$query = $this->db->get('users');				if($query->num_rows() == 1) {			$data = array(				'ckey' => md5($this->input->post('email').time())			);			$this->db->where('email', $this->input->post('email'));			$q = $this->db->update('users', $data);			if($q) {				return $data['ckey'];			} else {				return false;			}		} else {			return false;		}	}}